<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4.1判断年龄</title>
</head>

<body>
    <script>
        var age;
        age = prompt("请输入你的年龄:", "18");
        if (age < 14)
            document.write("你是儿童");
        else if (age < 24)
            document.write("你是青少年");
        else if (age < 40)
            document.write("你是青年人");
        else if (age < 60)
            document.write("你是中年人");
        else
            document.write("你是老年人");
    </script>
</body>

</html>